package com.irdstudio.efp.esb.service.impl.hj;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.irdstudio.efp.esb.common.client.resp.EsbRespSysHeadBean;
import com.irdstudio.efp.esb.common.constant.ESBTradeNoConstance;
import com.irdstudio.efp.esb.service.bo.req.hj.ReqDownLoadFileBean;
import com.irdstudio.efp.esb.service.client.ESBClientFactory;
import com.irdstudio.efp.esb.service.facade.hj.DownLoadFileService;

/**
 * 贷款文件下载通知
 * 
 * @description:TODO
 * @date:2019年1月4日 上午11:26:47
 * @author:cenyj
 */
@Service("downLoadFileService")
public class DownLoadFileServiceImpl implements DownLoadFileService {	
	Logger logger = LoggerFactory.getLogger(CustomerInfoCreateServiceImpl.class);

	public  boolean DownLoadFileNotice(ReqDownLoadFileBean reqDownLoadFileBean) {
		boolean rs=false;
		EsbRespSysHeadBean esbRespSysHeadBean = new EsbRespSysHeadBean();
		logger.info("根据文件名：" + reqDownLoadFileBean.getFileNm() + "通知互金");
		try {
			//MBSD_BP_LM-1220-0102 调用esb客户端服务ESBTradeNoConstance.DOWNLOADFILE
			esbRespSysHeadBean = ESBClientFactory.buildClient().withBody(reqDownLoadFileBean).withTradeNo("30220003").withScene("03").create()
					.sendAndReceive().getSysHead();
			String retCd = esbRespSysHeadBean.getRetInfArry().get(0).getRetCd();
			/*if(retCd.equals("888888") ) {
				logger.info("超时，重新通知互金");
				esbRespSysHeadBean = ESBClientFactory.buildClient().withBody(reqDownLoadFileBean).withTradeNo("30220003").withScene("03").create()
						.sendAndReceive().getSysHead();
				 retCd = esbRespSysHeadBean.getRetInfArry().get(0).getRetCd();				
			}*/
			if(retCd.equals("000000") == false) {
				logger.info("通知互金出错");
				rs=false;
			}
			//String retMsg = esbRespSysHeadBean.getRetInfArry().get(0).getRetMsg();
		} catch (Exception e) {
			logger.error(e.getMessage());
			logger.info("根据文件名：" + reqDownLoadFileBean.getFileNm() + "通知互金出错");
			rs=false;
		}
		rs=true;
		logger.info("根据文件名：" + reqDownLoadFileBean.getFileNm() + "通知互金结束");
return rs;
	}	
}
